import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '订单号',
    dataIndex: 'hehuanId',
    width: 160,
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    width: 160,
  },
  {
    title: '推荐人姓名',
    dataIndex: 'saleName',
    width: 100,
  },
  {
    title: '地区',
    dataIndex: 'orderNum',
    width: 100,
  },
  {
    title: '购买类型',
    dataIndex: 'type',
    width: 80,
    customRender: ({ record }: Recordable) => {
      const payStyles = [
        { label: '个人版', value: '0' },
        { label: '家庭版', value: '1' },
        { label: '个人版（员工内部）', value: '3' },
        { label: '家庭版（员工内部）', value: '4' },
      ];
      const payStyle: any = payStyles.find((item) => item.value == record.type);
      if (payStyle) {
        return payStyle.label;
      }
      return '';
    },
  },
  {
    title: '支付状态',
    dataIndex: 'payStyle',
    width: 80,
    customRender: ({ record }: Recordable) => {
      const payStyles = [
        { label: '未支付', value: '0' },
        { label: '支付成功', value: '1' },
        { label: '支付失败', value: '2' },
      ];
      const payStyle: any = payStyles.find((item) => item.value == record.payStyle);
      if (payStyle) {
        return payStyle.label;
      }
      return '';
    },
  },
  {
    title: '付款金额',
    dataIndex: 'pay',
    width: 100,
  },
  {
    title: '激活码',
    dataIndex: 'code',
    width: 120,
  },
  {
    title: '状态',
    dataIndex: 'style',
    width: 80,
    customRender: ({ record }: Recordable) => {
      const styles = [
        { label: '无', value: '0' },
        { label: '正常', value: '1' },
        { label: '已退', value: '2' },
      ];
      const style: any = styles.find((item) => item.value == record.style);
      if (style) {
        return style.label;
      }
      return '';
    },
  },
  {
    title: '创建日期',
    dataIndex: 'createDate',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderNum',
    label: '地区',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'phone',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'saleName',
    label: '推荐人',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'style',
    label: '状态',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '无', value: '0' },
        { label: '正常', value: '1' },
        { label: '已退', value: '2' },
      ],
    },
  },
  {
    field: 'payStyle',
    label: '支付状态',
    component: 'Select',
    colProps: { span: 5 },
    componentProps: {
      options: [
        { label: '未支付', value: '0' },
        { label: '支付成功', value: '1' },
        { label: '支付失败', value: '2' },
      ],
    },
  },
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 5 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];
